const service = axios.create({
  baseUrl: 'http://localhost:9900',
  timeout: 5000
});

axios.interceptors.request.use(config => {
    let token = JSON.parse(localStorage.getItem("jsbb-token"));
    if (token) {
        config.headers.token = token;
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});

axios.interceptors.response.use(response => {
    if (response.data.code == '9999') {
        parent.location.href ='/';
    }
    if(response.request.responseType == 'arraybuffer') {
        return response;
    }
    return response.data;
});
